package com.zoe.onelink.mybatis.pagination;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * <p>标题: 兼容旧版分页字段</p>
 * <p>描述: </p>
 * <p>版权: Copyright (c) 2021</p>
 * <p>公司: 智业软件股份有限公司</p>
 *
 * @version: 1.0
 * @author: ruansheng
 * @date: 2021-11-02
 */
public class Page<T> extends com.baomidou.mybatisplus.extension.plugins.pagination.Page<T> {

    private static final long serialVersionUID = -97369372307685558L;


    /**
     * 兼容旧版本
     * 当前页，对应current
     */
    private long page = 1;

    /**
     * 兼容旧版本
     * 每页显示条数，默认 10，对应size
     */
    private long pageSize = 10;

    /**
     * 当前页
     * 建议使用page(旧版规范)
     */
    @Deprecated
    @JsonIgnore
    protected transient long current = page;

    /**
     * 每页显示条数，默认 10
     * 建议使用pageSize(旧版规范)
     */
    @Deprecated
    @JsonIgnore
    protected transient long size = pageSize;

    public Page() {

    }

    public Page(long page, long pageSize) {
        this.page = page;
        this.pageSize = pageSize;
        this.current = page;
        this.size = pageSize;
    }


    public long getPage() {
        return this.page;
    }

    public void setPage(long page) {
        this.page = page;
        this.current = page;
    }

    public long getPageSize() {
        return this.pageSize;
    }

    public void setPageSize(long pageSize) {
        this.pageSize = pageSize;
        this.size = pageSize;
    }

    @Override
    public long getCurrent() {
        return this.getPage();
    }

    @Override
    public long getSize() {
        return this.getPageSize();
    }

    @Override
    public com.baomidou.mybatisplus.extension.plugins.pagination.Page<T> setCurrent(long current) {
        this.page = current;
        return super.setCurrent(current);
    }

    @Override
    public com.baomidou.mybatisplus.extension.plugins.pagination.Page<T> setSize(long size) {
        this.pageSize = size;
        return super.setSize(size);
    }
}
